package bTree.LeetCode;

import java.util.List;

public class 奇偶链表 {
    public ListNode oddEvenList(ListNode head) {
        if (head==null){
            return head;
        }
        if (head.next==null){
            return head;
        }
        if (head.next.next==null){
            return head;
        }
        int leftCnt=1;
        ListNode left=head,right=head.next.next;
        ListNode Double=head.next;
        while (right!=null){
            ListNode temp=left.next;
            left.next=right;
            left=temp;
            right=right.next;
            leftCnt++;
        }
        if (leftCnt%2==0){
            left.next.next=Double;
            left.next=null;
        }else {
            left.next=Double;
        }
        return head;



    }
}